﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditCrmManager.aspx.cs"
    Inherits="ZX.WebApp.Crm.Customer.EditCrmManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link href="../../Styles/base.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/default/calendar.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.calendar.js" type="text/javascript"></script>
    <script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
    <script src="../../Scripts/extend.validate.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        /* Table样式 */
         body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; background: #eeeeee;}
        /* Table样式 */
       
        textarea 
        {
            height:100px;
        }
        label
        {
            font-size:14px;
            text-align:right;
            width:200px;
        } .birthday
        {
        text-align:center;
            width:30px;
            border:0 0 0 0px;
            border-bottom:1px solid black;

            }
        .btn 
        { 
            border-right: #7b9ebd 1px solid; 
            padding-right: 2px; 
            border-top: #7b9ebd 1px solid; 
            padding-left: 2px; 
            font-size: 12px; 
            FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,  StartColorStr=#ffffff,  EndColorStr=#cecfde); 
            border-left: #7b9ebd 1px solid; 
            cursor: hand; 
            color: black; 
            height:24px;
            padding-top: 2px; 
            border-bottom: #7b9ebd 1px solid; 
        } 

   </style>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <div id="toolbar" style="margin: 2px;">
        <button type="button" id="btnSave" name="btnSave">
            保存退出</button>
        <button type="reset" id="btnFull" name="btnFull">
            重置</button>
        <button type="button" id="btnClose" name="btnClose">
            退出</button>
    </div>
    <div class="fieldForm" id="fieldForm">
        <table class="tableContent">
            <tr>
                <td>
                    <fieldset>
                        <legend>&nbsp;基本信息</legend>
                        <table class="tableContent">
                            <tr>
                                <td width="100">
                                    &nbsp;联系人编码：<span style="color: Red">*</span>
                                </td>
                                <td width="308">
                                    <asp:TextBox ID="Code" runat="server" Enabled="false" Width="150px" BackColor="Beige"></asp:TextBox>
                                    <span class="span_font">系统自动生成</span>
                                </td>
                                <td width="100">
                                    &nbsp;客户选择：<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <input type="hidden" id="CustomId" runat="server" name="CustomId" />
                                    <input id="txtCustomId" runat="server" name="txtCustomId" type="text" readonly="readonly"
                                        style="width: 150px;" />
                                    <button id="btnCustomId" name="L" type="button" class="btn">
                                        选择</button>
                                    <span class="span_font">请选择对的客户名称</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;联系人名字：<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <asp:TextBox ID="Caption" MaxLength="10" Width="150" runat="server"></asp:TextBox>
                                    <span class="span_font">请填写对的客户名字</span>
                                </td>
                                <td width="100">
                                    &nbsp;联系人类型：<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <asp:DropDownList ID="TypeID" runat="server" Width="160">
                                    </asp:DropDownList>
                                    <span class="span_font">请选择对的类型</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;与决策人关系：<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <asp:DropDownList ID="Relation" runat="server" AppendDataBoundItems="true" Width="160">
                                        <asp:ListItem Value=""> </asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                                <td width="100">
                                    &nbsp;职位：<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <asp:TextBox ID="Position" MaxLength="10" Width="150" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;所属部门：
                                </td>
                                <td>
                                    <asp:TextBox ID="DeptName" MaxLength="10" Width="150" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;性别：<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <asp:DropDownList ID="Sex" runat="server" Width="160">
                                        <asp:ListItem Value="0">--请选择--</asp:ListItem>
                                        <asp:ListItem Value="M">男</asp:ListItem>
                                        <asp:ListItem Value="F">女</asp:ListItem>
                                    </asp:DropDownList>
                                    <span class="span_font">请选择对的性别</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;生日类型：
                                </td>
                                <td>
                                    <asp:DropDownList ID="BirthdayType" runat="server" Width="160">
                                        <asp:ListItem Value="0">--请选择--</asp:ListItem>
                                        <asp:ListItem Value="1">农历</asp:ListItem>
                                        <asp:ListItem Value="2">阳历</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                                <td width="100">
                                    &nbsp;生日：
                                </td>
                                <td>
                                    <input type="text" id="EXP3" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                                        onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="4" class="birthday" />年
                                    <input type="text" id="EXP4" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                                        onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="2" class="birthday" />月<input
                                            type="text" id="Drink" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                                            onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="2" class="birthday" />日
                                    <input runat="server" type="text" readonly="readonly" class="yui-date" dtype="D"
                                        id="Birthday" name="Birthday" style="width: 150; display: none;" />
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;民族：
                                </td>
                                <td>
                                    <asp:TextBox ID="Nation" MaxLength="20" Width="150" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;饮食习惯：
                                </td>
                                <td>
                                    <asp:TextBox ID="Dish" MaxLength="20" Width="150" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;毕业学校：
                                </td>
                                <td>
                                    <asp:TextBox ID="SchoolUntity" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;专业：
                                </td>
                                <td>
                                    <asp:TextBox ID="Schoolspeciality" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;爱好：
                                </td>
                                <td>
                                    <asp:TextBox ID="LinkManFancy" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;宗教信仰：
                                </td>
                                <td>
                                    <asp:TextBox ID="Religion" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;籍贯：
                                </td>
                                <td>
                                    <asp:TextBox ID="Homeplace" MaxLength="20" Width="150" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;病史：
                                </td>
                                <td>
                                    <asp:TextBox ID="Medical" Width="150" MaxLength="100" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
            <tr>
                <td>
                    <fieldset>
                        <legend>&nbsp;联系方式</legend>
                        <table class="tableContent">
                            <tr>
                                <td width="100">
                                    &nbsp;手机号：<span style="color: Red">*</span>
                                </td>
                                <td width="308">
                                    <asp:TextBox ID="MobileTel" MaxLength="11" runat="server" Width="150" onblur="CheckTel(this.value,'手机','MobileTel','Email');"
                                        onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g))"></asp:TextBox><span
                                            id="tempNum" class="span_font"> 请填写对的手机号码</span>
                                </td>
                                <td width="100">
                                    &nbsp;邮箱：
                                </td>
                                <td>
                                    <asp:TextBox ID="Email" onblur="isEmail(this.value)" Width="150" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;办公电话：
                                </td>
                                <td>
                                    <asp:TextBox ID="OfficeTel" Width="150" MaxLength="20" onkeyup="this.value=this.value.replace(/\D/g,'')"
                                        onafterpaste="this.value=this.value.replace(/\D/g,'')" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;个人网址：
                                </td>
                                <td>
                                    <asp:TextBox ID="Netting" Width="150" MaxLength="40" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;QQ：
                                </td>
                                <td>
                                    <asp:TextBox ID="HoliType" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
                                        MaxLength="20" Width="150" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;微博：
                                </td>
                                <td style="text-align: left;">
                                    <asp:TextBox ID="txtWeibo" Width="150" MaxLength="50" ToolTip="最多能输入50个字" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;家庭电话：
                                </td>
                                <td>
                                    <asp:TextBox ID="HomeTel" Width="150" onkeyup="this.value=this.value.replace(/\D/g,'')"
                                        onafterpaste="this.value=this.value.replace(/\D/g,'')" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;传真：
                                </td>
                                <td>
                                    <asp:TextBox ID="Fax" Width="150" onkeyup="this.value=this.value.replace(/\D/g,'')"
                                        onafterpaste="this.value=this.value.replace(/\D/g,'')" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;地址：
                                </td>
                                <td colspan="3">
                                    <asp:TextBox ID="Address" Width="563" MaxLength="100" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;备注：
                                </td>
                                <td colspan="3">
                                    <asp:TextBox ID="Explain" title="最多可输入100个汉字" MaxLength="100" Width="563" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;再来一条：
                                </td>
                                <td colspan="3">
                                    <input id="onceMore" name="onceMore" type="checkbox" /><span class="span_font"> 选中后，提交可以继续在本页面添加联系人
                                        &nbsp;&nbsp;&nbsp; <font color="red">注：*&nbsp; 为必填项</font></span>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
            <tr>
                <td>
                    <fieldset>
                        <legend>&nbsp;配偶信息</legend>
                        <table class="tableContent">
                            <tr>
                                <td width="100">
                                    &nbsp;名字：
                                </td>
                                <td width="308">
                                    <asp:TextBox ID="FereName" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;籍贯：
                                </td>
                                <td>
                                    <asp:TextBox ID="FereHomeplace" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;爱好：
                                </td>
                                <td>
                                    <asp:TextBox ID="FereFancy" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;民族：
                                </td>
                                <td>
                                    <asp:TextBox ID="FereNation" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;生日：
                                </td>
                                <td>
                                    <asp:TextBox ID="FereBirthday" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;所在单位：
                                </td>
                                <td>
                                    <asp:TextBox ID="FereCompany" Width="150" MaxLength="40" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
            <tr>
                <td>
                    <fieldset>
                        <legend>&nbsp;子女信息</legend>
                        <table class="tableContent">
                            <tr>
                                <td width="100">
                                    &nbsp;名字：
                                </td>
                                <td width="308">
                                    <asp:TextBox ID="ChildName" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;籍贯：
                                </td>
                                <td>
                                    <asp:TextBox ID="EXP2" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;爱好：
                                </td>
                                <td>
                                    <asp:TextBox ID="ChildFancy" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;民族：
                                </td>
                                <td>
                                    <asp:TextBox ID="EXP1" Width="150" MaxLength="20" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="100">
                                    &nbsp;生日：
                                </td>
                                <td>
                                    <asp:TextBox ID="ChildBirthday" MaxLength="20" Width="150" runat="server"></asp:TextBox>
                                </td>
                                <td width="100">
                                    &nbsp;所在单位/学校：
                                </td>
                                <td>
                                    <asp:TextBox ID="ChildCompany" MaxLength="40" Width="150" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
        </table>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            客户选择</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <asp:HiddenField ID="ID" runat="server" />
    <asp:HiddenField ID="AddUser" runat="server" Value="00000000-0000-0000-0000-000000000000" />
    <asp:HiddenField ID="AddTime" runat="server" />
    </form>
    <form id="form2" action="../../Extend/AjaxData/DataSave.aspx">
    <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    </form>
</body>
<script type="text/javascript">
    //function document.oncontextmenu() { event.returnValue = false; } //屏蔽鼠标右键
    var instance = [{ "Caption": "aaaaaaaaa"}];
    var action = "<% =DataAction %>", condition = "";
    (function () {
        var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
        Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                units: [
                { position: 'top', height: 35, body: 'toolbar', gutter: '1 1 1 1', scroll: null, zIndex: 2 },
                { position: 'center', body: 'fieldForm', gutter: '0 1 1 1', scroll: true }
            ]
            });
            layout.render();
        });
    })();
    YAHOO.example.init = function () {
        function onButtonClick(p_oEvent) {
            switch (this.get("id")) {
                case "btnSave":
                    CheckDecisionTel();
                    break;
                case "btnFull":
                    clearForm();
                    break;
                case "btnClose":
                    WinClose();
                    break;

                default:
                    break;
            }
        }
        YAHOO.util.Event.onContentReady("toolbar", function () {
            var btnSave = new YAHOO.widget.Button("btnSave");
            btnSave.on("click", onButtonClick);
            var btnFull = new YAHOO.widget.Button("btnFull");
            btnFull.on("click", onButtonClick);
            var btnClose = new YAHOO.widget.Button("btnClose");
            btnClose.on("click", onButtonClick);

        });

    } ();

    YAHOO.namespace("example.container");
    YAHOO.util.Event.onDOMReady(function () {
        var handleSubmit = function () {
            var editwindow = document.getElementById("EditUIWindow1");
            if (editwindow) {
                editwindow.contentWindow.ChooseInfo();
            }
            YAHOO.example.container.dialog1.hide();
        };

        var handleCancel = function () {
            this.cancel();
        };
        var handleSuccess = function (o) {
            var response = o.responseText;
            response = response.split("<!")[0];
            document.getElementById("resp").innerHTML = response;
        };
        var handleFailure = function (o) {
            alert("Submission failed: " + o.status);
        };
        YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					            { width: "650px",
					                height: "480px",
					                fixedcenter: true,
					                visible: false,
					                draggable: true,
					                close: true,
					                autofillheight: "body",
					                constraintoviewport: true,
					                buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								            { text: "取消", handler: handleCancel}]
					            });
        YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
        YAHOO.example.container.dialog1.render();
        //拖动大小
        var resize = new YAHOO.util.Resize("dialog1", {
            handles: ["br"],
            autoRatio: false,
            minWidth: 650,
            minHeight: 450,
            status: false
        });
        resize.on("startResize", function (args) {
            if (this.cfg.getProperty("constraintoviewport")) {
                var D = YAHOO.util.Dom;
                var clientRegion = D.getClientRegion();
                var elRegion = D.getRegion(this.element);
                resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
                resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
            } else {
                resize.set("maxWidth", null);
                resize.set("maxHeight", null);
            }
        }, YAHOO.example.container.dialog1, true);
        resize.on("resize", function (args) {
            var panelHeight = args.height;
            this.cfg.setProperty("height", panelHeight + "px");
        }, YAHOO.example.container.dialog1, true);
    });

    var callback = {
        success: responseSuccess,
        failure: responseFailure
    };
    /*客户选择对应的方法和ID*/
    var _fn, _id;
    function ShowDialog(fn, id, src) {
        _fn = fn;
        _id = id;
        document.getElementById("EditUIWindow1").src = src;
        YAHOO.example.container.dialog1.show();
    }
    function setValue() {
        instance[0].ID = $("#ID").val();
        instance[0].Code = $('#Code').val();
        instance[0].CustomId = $('#CustomId').val();
        instance[0].Caption = $('#Caption').val();
        instance[0].TypeID = $('#TypeID').val();
        instance[0].Sex = $('#Sex').val();
        instance[0].Nation = $('#Nation').val();
        instance[0].Position = $('#Position').val();
        instance[0].Birthday = $('#Birthday').val();
        instance[0].DeptName = $('#DeptName').val();
        instance[0].Medical = $('#Medical').val();
        instance[0].Religion = $('#Religion').val();
        instance[0].Homeplace = $('#Homeplace').val();
        instance[0].BirthdayType = $('#BirthdayType').val();
        instance[0].SchoolUntity = $('#SchoolUntity').val();
        instance[0].Schoolspeciality = $('#Schoolspeciality').val();
        instance[0].LinkManFancy = $('#LinkManFancy').val();
        instance[0].MobileTel = $('#MobileTel').val();
        instance[0].Email = $('#Email').val();
        instance[0].OfficeTel = $('#OfficeTel').val();
        instance[0].Netting = $('#Netting').val();
        instance[0].HoliType = $('#HoliType').val();
        instance[0].Fax = $('#Fax').val();
        instance[0].HomeTel = $('#HomeTel').val();
        instance[0].Address = $('#Address').val();
        instance[0].Explain = $('#Explain').val();
        instance[0].FereName = $('#FereName').val();
        instance[0].FereHomeplace = $('#FereHomeplace').val();
        instance[0].FereFancy = $('#FereFancy').val();
        instance[0].FereNation = $('#FereNation').val();
        instance[0].FereBirthday = $('#FereBirthday').val();
        instance[0].FereCompany = $('#FereCompany').val();
        instance[0].ChildName = $('#ChildName').val();
        instance[0].ChildBirthday = $('#ChildBirthday').val();
        instance[0].ChildFancy = $('#ChildFancy').val();
        instance[0].Exp1 = $("#Exp1").val(); //民族
        instance[0].Exp2 = $("#Exp2").val(); //籍贯
        instance[0].EXP3 = $("#EXP3").val(); //年
        instance[0].EXP4 = $("#EXP4").val(); //月     
        instance[0].Drink = $("#Drink").val(); //日
        instance[0].ChildCompany = $("#ChildCompany").val();
        instance[0].Dish = $("#Dish").val();
        instance[0].AddUser = $("#AddUser").val();
        instance[0].AddTime = $("#AddTime").val();
        instance[0].Weibo = $("#txtWeibo").val();
        instance[0].Relation = $("#Relation").val();
    }
    //重置
    var clearForm = function () {
        location.reload(false)
    };
    //邮箱验证
    function isEmail(val) {
        if (val != "") {
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;
            if (!myreg.test(val)) {
                alert("邮箱格式不合法!");
                $('#Email').focus();
                document.getElementById("Email").value = "";
                return;
            }
        }
    }
    //客户端验证
    var checkData = function () {    
        if ($("#txtCustomId").val() == "") {
            alert("客户必须选择");
            $("#txtCustomId").focus();
            return false;
        }
        if ($("#Caption").val() == "") {
            alert("联系人名称不能为空");
            $("#Caption").focus();
            return false;
        }
        if ($("#TypeID").val() == "00000000-0000-0000-0000-000000000000") {
            alert("联系人类型必须选择");
            $("#TypeID").focus();
            return false;
        }
        if ($("#Relation").val() == "") {
            alert("与决策人关系不能为空!");
            $("#Relation").focus();
            return;
        }
        if ($("#Position").val() == "") {
            alert("职位不能为空");
            $("#Position").focus();
            return false;
        }
        if ($("#Sex").val() == "0") {
            alert("性别必须选择");
            $("#Sex").focus();
            return false;
        } 
        if ($("#MobileTel").val() == "") {
            alert("请输入有效的手机号");
            $("#MobileTel").focus();
            return false;
        }
        var num = $("#MobileTel").val().length;
        if (num != 11) {
            alert("手机号码必须是11位");
            $('#MobileTel').focus();
            return false;
        }
        return true;
    }
    //重置
    var clearForm = function () {
        location.reload(false)
    };
    //保存
    var Save = function () {
        if (checkData()) {
            setValue();
            var entity = "CrmLinkMan";
            var url = "../../Extend/AjaxData/DataSave.aspx";
            $("#jsonDataContent").val($.toJSON(instance[0]));
            var SaveUrl = url + "?r=" + Math.random() + "&entity=" + entity + "&action=" + action + "&json=" + encodeURI($("#jsonDataContent").val().replace(/&/g, "[A]").replace(/'/g, "[B]"));
            //发送保存请求
            YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                success: responseSuccess,
                failure: responseFailure
            }, null);

        } else {
            return;
        }
    }
    //提示已输入位数
    var ckNum = function () {
        //        var innerValues = "&nbsp;您输入的位数是<font color='red'>" + $("#MobileTel").val().length + "</font>位";
        //        document.getElementById("tempNum").innerHTML = innerValues;

    }
    //检查联系人手机是否已存在
    function CheckDecisionTel() {
        var Url = "../../Extend/AjaxData/CustomOperating.aspx";
        var vDecisionTel = $('#MobileTel').val();
        var vValue = vDecisionTel;
        var vid = "<%=getId %>";
        if (vValue != "") {
            YAHOO.util.Connect.asyncRequest('POST', Url + "?r=" + Math.random() + "&id=" + vid + "&temp=" + action + "&entity=CrmLinkTel&action=check&cid=" + $('#CustomId').val() + "&cname=" + encodeURI($('#Caption').val()) + "&tel=" + encodeURI(vValue) + "", //条件 
            {success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "2") {
                        if (confirm("该联系人已存在,您确定要保存？")) {
                            Save();
                            return;
                        } else {
                            $('#Caption').focus();
                            return;
                        }
                    }
                    if (str == "1") {
                        if (confirm("该联系人手机已经存在,您确定要保存？")) {
                            Save();
                            return;
                        } else {
                            $('#MobileTel').focus();
                            return;
                        }
                    } Save();
                }
                catch (e) {
                    return;
                }
                finally {
                }
            }, failure: function () { return; }
        });
    } else {
        alert("联系人手机不能为空!");
        $('#MobileTel').focus();
        return;
    }
}
var WinClose = function () {
    window.parent.$("#tabs").tabs('close', '新增联系人信息');
    window.parent.$("#tabs").tabs('close', '编辑联系人信息');
    parent.NeedRefreshPage.RefreshData();
};

var responseSuccess = function (res) {
    try {
        var str = res.responseText;
        if (str == "1") {
            if (document.getElementById("onceMore").checked) {
                alert("数据保存成功");
                clearForm();
            } else {
                alert("数据保存成功");
                //                        if ($("#onceMore").val()) {

                //                        }                              
                WinClose();
            }
        }
        else {
            alert(str + "\n" + "数据保存失败!");
        }
    }
    catch (e) {
    }
    finally {
    }
};
var responseFailure = function (error) {
    alert("数据错误：" + error.statusText);
}
$(document).ready(function () {
    $('#Birthday').cld();

});  
</script>
<script src="../../Scripts/appjs/model.<% =EntityName %>.js" type="text/javascript"
    language="javascript"></script>
</html>
